package com.xiaoyi.common.exception;

import com.xiaoyi.entity.ResultBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 小易
 * @version 1.0
 * @description TODO 全局异常处理器
 * @date 2022/12/6 16:33
 */

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = RuntimeException.class)
    public ResultBody handler(RuntimeException e){
        log.error("运行时异常：---------------{}", e.getMessage());
        e.printStackTrace();
        return ResultBody.error(e.getMessage());
    }

}
